package com.wn.sk.common.jwt;

import cn.hutool.jwt.JWTUtil;

import java.util.HashMap;

/**
 * @author yellow Docter
 * @date 2022 -09-06
 * @desc  测试jwt封装的操作
 */
public class Demo02 {

    public static void main(String[] args) {

        JwtTemplate jwtTemplate = new JwtTemplate();

        //创建
        HashMap<String, Object> payload = new HashMap<>();

        payload.put("name","hello");
        payload.put("age",20);

        String token = jwtTemplate.createToken(payload);
        System.out.println("token = " + token);
        //验证
        boolean b = jwtTemplate.verifyToken(token);
        System.out.println("b = " + b);

        //解析
        Object name = jwtTemplate.parseToken(token, "name");
        System.out.println("name = " + name);

        Object age = jwtTemplate.parseToken(token, "age");
        System.out.println("age = " + age);

    }

}


